import { GTextFormat } from "../../common/GTextFormat";
import { FontUtil } from "../../common/font/FontUtil";
import { LayerManager } from "./LayerManager";
import { TweenMax } from "../../../com/greensock/TweenMax";
import { FilterConst } from "../../component/gconst/FilterConst";
type int = number;
//class MsgSceneInfoImpl
    
    export  class MsgSceneInfoImpl /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._sceneInfoCache = new Map<any, any> /* flash.utils.Dictionary */();
            this._bmp = new Object /* flash.display.Bitmap */();
            this._desTxts = new Map<any, any> /* flash.utils.Dictionary */();
            this._infoTxtFormat = new GTextFormat(FontUtil.lishuName, 20, 16777215, false);
            this._infoTxtFormat.leading = 0;
            this._infoTxtFormat.align = flash.text.TextFormatAlign.LEFT;
            mouseEnabled = false;
            mouseChildren = false;
            this._bmp.x = 270;
            this._bmp.y = 150;
            return;
        }

        public showMsg(arg1: string, arg2: Array<any>): void
        {
            this.hideMsg();
            if (!this._sceneInfoCache[arg1]) 
            {
                this.createSceneCache(arg1, arg2);
            }
            this._bmp.bitmapData = this._sceneInfoCache[arg1];
            this._bmp.alpha = 0;
            LayerManager.highestLayer.addChild(this._bmp);
            this.stageReseze();
            this._inTween = TweenMax.to(this._bmp, 3, {"alpha": 1, "onComplete": this.onInEnd});
            return;
        }

        /* internal  */createSceneCache(arg1: string, arg2: Array<any>): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=null;
            if (!this._titleTxt) 
            {
                this._titleTxt = this.createTitleTxt();
                addChild(this._titleTxt);
            }
            this._titleTxt.text = arg1;
            var loc2=arg2.length;
            while (loc1 < loc2) 
            {
                loc3 = arg2[loc1];
                if (!(loc4 = this._desTxts[loc1])) 
                {
                    loc4 = this.createInfoTxt(loc1);
                    this._desTxts[loc1] = loc4;
                }
                loc4.text = loc3;
                addChild(loc4);
                ++loc1;
            }
            alpha = 1;
            filters = [FilterConst.nameGlowFilter, FilterConst.sceneDesFilter];
            var loc5;
            (loc5 = new Object /* flash.display.BitmapData */(this.width, this.height, true, 0)).draw(this);
            this._sceneInfoCache[arg1] = loc5;
            return;
        }

        /* internal  */createInfoTxt(arg1: int): Object /* flash.text.TextField */
        {
            var loc1=null;
            loc1 = new Object /* flash.text.TextField */();
            loc1.defaultTextFormat = this._infoTxtFormat;
            loc1.width = 28;
            loc1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc1.multiline = true;
            loc1.wordWrap = true;
            loc1.mouseEnabled = false;
            loc1.x = 35 + arg1 * loc1.width;
            loc1.y = 30;
            return loc1;
        }

        /* internal  */createTitleTxt(): Object /* flash.text.TextField */
        {
            var loc1=new Object /* flash.text.TextField */();
            var loc2=new GTextFormat(FontUtil.lishuName, 25, 16777215, false);
            loc2.leading = 0;
            loc2.align = flash.text.TextFormatAlign.LEFT;
            loc1.defaultTextFormat = loc2;
            loc1.width = 32;
            loc1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc1.multiline = true;
            loc1.wordWrap = true;
            loc1.mouseEnabled = false;
            return loc1;
        }

        /* internal  */onInEnd(): void
        {
            this._timerKey = flash.utils.setTimeout(this.onTimeOut, 3000);
            return;
        }

        /* internal  */onTimeOut(): void
        {
            this._outTween = TweenMax.to(this._bmp, 3, {"alpha": 0, "onComplete": this.onOutEnd});
            return;
        }

        /* internal  */onOutEnd(): void
        {
            this.hideMsg();
            return;
        }

        public hideMsg(): void
        {
            var loc2=null;
            flash.utils.clearTimeout(this._timerKey);
            if (this._inTween && this._inTween.active) 
            {
                this._inTween.kill();
            }
            if (this._outTween && this._outTween.active) 
            {
                this._outTween.kill();
            }
            if (this._bmp && !(this._bmp.parent == null)) 
            {
                this._bmp.parent.removeChild(this._bmp);
            }
            if (this._titleTxt) 
            {
                this._titleTxt.text = "";
            }
            var loc1=1;
            while (loc1 < numChildren) 
            {
                loc2 = removeChildAt(loc1) as Object /* flash.text.TextField */;
                loc2.text = "";
            }
            return;
        }

        public stageReseze(): void
        {
            return;
        }

        public /* override */ get width(): number
        {
            return 32 + (numChildren - 1) * 30;
        }

        public /* override */ get height(): number
        {
            return 500;
        }

        /* internal */ /* var */_sceneInfoCache: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_bmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_titleTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_desTxts: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_infoTxtFormat: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_inTween: TweenMax;

        /* internal */ /* var */_outTween: TweenMax;

        /* internal */ /* var */_timerKey: uint;
    }
